<?php

use Decorator\Concrete\DecoratorA;
use Decorator\Concrete\DecoratorB;
use Decorator\ConcreteComponent;

include_once "Concrete/DecoratorA.php";
include_once "Concrete/DecoratorB.php";
include_once "ConcreteComponent.php";

/** 实例化需要装饰的具体对象 */
$component = new ConcreteComponent();

/** 实例化想要增加的装饰具体对象 */
$a = new DecoratorA();
/** 设置装饰对象 */
$a->setDecoratorObject($component);

$b = new DecoratorB();
/** 设置装饰对象 */
$b->setDecoratorObject($a);

/** 执行装饰 */
$b->operation();

echo "装饰完成" . PHP_EOL;